import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '请假类型',
    align: "center",
    dataIndex: 'leaveType_dictText'
  },
  {
    title: '人员',
    align: "center",
    dataIndex: 'userId_dictText'
  },
  {
    title: '开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'startDate'
  },
  {
    title: '结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'endDate'
  },
  {
    title: '时长(H)',
    align: "center",
    dataIndex: 'leaveDuration'
  },
  {
    title: '是否有风险',
    align: "center",
    dataIndex: 'isRisk_dictText'
  },
  {
    title: '是否交接',
    align: "center",
    dataIndex: 'isHandover_dictText'
  },
  {
    title: '交接人',
    align: "center",
    dataIndex: 'handover_dictText'
  },
  {
    title: '休假原因',
    align: "center",
    dataIndex: 'leaveComment'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "请假类型",
    field: 'leaveType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "leave_type"
    },
    //colProps: {span: 6},
  },
  {
    label: "开始时间",
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
    },
    //colProps: {span: 6},
  },
  {
    label: "结束时间",
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
    },
    //colProps: {span: 6},
  },
  {
    label: "是否有风险",
    field: 'isRisk',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yes_or_no"
    },
    //colProps: {span: 6},
  },
  {
    label: "是否交接",
    field: 'isHandover',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yes_or_no"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '请假类型',
    field: 'leaveType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "leave_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入请假类型!'},
             ];
    },
  },
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开始时间!'},
             ];
    },
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入结束时间!'},
             ];
    },
  },
  {
    label: '时长(H)',
    field: 'leaveDuration',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入时长(H)!'},
             ];
    },
  },
  {
    label: '是否有风险',
    field: 'isRisk',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yes_or_no"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否有风险!'},
             ];
    },
  },
  {
    label: '是否交接',
    field: 'isHandover',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yes_or_no"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否交接!'},
             ];
    },
  },
  {
    label: '交接人',
    field: 'handover',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入交接人!'},
             ];
    },
  },
  {
    label: '休假原因',
    field: 'leaveComment',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入休假原因!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'list', type: 'string',dictTable: 'tm_project', dictCode: 'id', dictText: 'project_name',},
  leaveType: {title: '请假类型',order: 1,view: 'list', type: 'string',dictCode: 'leave_type',},
  userId: {title: '人员',order: 2,view: 'sel_user', type: 'string',},
  startDate: {title: '开始时间',order: 3,view: 'datetime', type: 'string',},
  endDate: {title: '结束时间',order: 4,view: 'datetime', type: 'string',},
  leaveDuration: {title: '时长(H)',order: 5,view: 'number', type: 'number',},
  isRisk: {title: '是否有风险',order: 6,view: 'list', type: 'string',dictCode: 'yes_or_no',},
  isHandover: {title: '是否交接',order: 7,view: 'list', type: 'string',dictCode: 'yes_or_no',},
  handover: {title: '交接人',order: 8,view: 'sel_user', type: 'string',},
  leaveComment: {title: '休假原因',order: 9,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 10,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 11,view: 'datetime', type: 'string',},
};
